package org.dizem.groupon.service.impl;

import org.dizem.groupon.dao.MerchantDAO;
import org.dizem.groupon.model.domain.MerchantEntity;
import org.dizem.groupon.service.MerchantService;

import java.util.List;

/**
 * User: dizem@126.com
 * Time: 11-6-28 下午3:07
 */
public class MerchantServiceImpl implements MerchantService {
	private MerchantDAO merchantDAO;

	public MerchantDAO getMerchantDAO() {
		return merchantDAO;
	}

	public void setMerchantDAO(MerchantDAO merchantDAO) {
		this.merchantDAO = merchantDAO;
	}

	public void save(MerchantEntity object) {
		merchantDAO.save(object);
	}

	public void delete(MerchantEntity object) {
		merchantDAO.delete(object);
	}

	public void update(MerchantEntity object) {
		MerchantEntity merchant = merchantDAO.getByName(object.getName());
		merchant.setAddress(object.getAddress());
		merchant.setBankName(object.getBankName());
		merchant.setBankNumber(object.getBankNumber());
		merchant.setPassword(object.getPassword());
		merchant.setPhoneNumber(object.getPhoneNumber());
		merchant.setUrl(object.getUrl());
		merchantDAO.update(merchant);
	}

	public MerchantEntity getById(int id) {
		return merchantDAO.getById(id);
	}

	public List<MerchantEntity> loadAll() {
		return merchantDAO.loadAll();
	}

	public List<MerchantEntity> load(int firstResult, int maxResult) {
		return merchantDAO.load(firstResult, maxResult);
	}

	public int getCount() {
		return merchantDAO.getCount();
	}
}
